package com.example.customview.expandtextview

import android.annotation.SuppressLint
import android.os.Build
import android.text.Layout
import android.text.SpannableStringBuilder
import android.text.Spanned
import android.text.StaticLayout
import android.util.Log
import androidx.core.content.ContextCompat
import com.alibaba.android.arouter.facade.annotation.Route
import com.android.baselibrary.base.BaseFragment
import com.example.customview.R
import com.example.customview.arouter.CustomArouter
import com.example.customview.databinding.FragmentExpandBinding
import com.google.android.material.internal.ViewUtils

@Route(path = CustomArouter.CUSTOM_EXPAND_VIEW)
class ExpandFragment :BaseFragment<FragmentExpandBinding>() {
    override fun getLayoutID() = R.layout.fragment_expand

    @SuppressLint("SuspiciousIndentation")
    override fun initView() {
        mBinding.expandTextView.initWidth(2)
        mBinding.expandTextView.setAtIds(listOf("#今天天气很好","#明天天气不好"))
        mBinding.expandTextView.setCloseText("大幅度所所所所所所所所所#今天天气很好爱上范德萨发放给大哥#明天天气不好打算复读撒发所所所所所")

        mBinding.expandLayout.setTextContent("大幅度所所所所所所所所所#今天天气很好爱上范德萨发放给大哥#明天天气不好打算复读撒发所所所所所", listOf("#今天天气很好","#明天天气不好"))
        //expandTextView.setCloseText("大幅度所所所所所所所所所#今天天气很好爱上范德萨发放给大哥#明天天气不好打算复读撒发所所所所所大幅度所所所所所所所所所#今天天气很好爱上范德萨发放给大哥#明天天气不好打算复读撒发所所所所所大幅度所所所所所所所所所#今天天气很好爱上范德萨发放给大哥#明天天气不好打算复读撒发所所所所所大幅度所所所所所所所所所#今天天气很好爱上范德萨发放给大哥#明天天气不好打算复读撒发所所所所所大幅度所所所所所所所所所#今天天气很好爱上范德萨发放给大哥#明天天气不好打算复读撒发所所所所所大幅度所所所所所所所所所#今天天气很好爱上范德萨发放给大哥#明天天气不好打算复读撒发所所所所所")
        val string = "大幅度所所所所所所所所所今天天气很好"
        /* mBinding.tvReport.post {
             val spannableString =  SpannableStringBuilder()
             val layout = mBinding.tvReport.layout
             Log.i("TAGas", "initView: u${layout.lineCount}")
             if (layout.lineCount==2){
                 val lineEnd = layout.getLineEnd(1)
                 Log.i("TAGas", "initView: u$lineEnd")
                 val result = string.substring(0,lineEnd-2)
                 Log.i("TAGas", "initView: u$result")
                 spannableString.clear();
                 spannableString.append(result).append("...  ");

             }
*/
          /*   val d = ContextCompat.getDrawable(requireContext(),R.drawable.cm_car_ad_edit)!!
             d.setBounds(0, 0, d.minimumWidth, d.minimumHeight)
             val imageSpan = MyIm(d)
             spannableString.setSpan(imageSpan,spannableString.length -2,
                 spannableString.length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE)*/



             mBinding.tvReport.setTexContent(string)
         }
    }

